import requests
import re














# 构造 Ollama API 请求
ollama_url = "http://localhost:11434/api/chat"  # Ollama 默认运行在本地 11434 端口
data = {
    "model": "deepseek-r1:8b",  # 模型名称，根据实际情况选择
    "messages": [
        {"role":"system","content":"你是中国股票分析大师,请你用中文回答接下来的问题"},
        {"role": "user", "content": "你好"}
    ],
    "stream": False  # 设置为 False，直接返回完整响应
}

# 调用 Ollama API

response = requests.post(ollama_url, json=data)
response.raise_for_status()
ollama_response = response.json()
assistant_message = ollama_response.get('message', {}).get('content', 'No response from model')
# print(assistant_message)
assistant_message = re.findall(r'</think>(.*)',assistant_message,re.DOTALL)[0]
print(assistant_message)
new_session_id = ollama_response.get('session_id')  # 获取新的会话 ID


